package com.xxxx.ssm.controller;

import com.xxxx.ssm.po.User;
import com.xxxx.ssm.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@Controller
public class HelloController {
    @Resource
    private UserService userService;

    @RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView mv = new ModelAndView();
        //调用service层查询方法
        User user = userService.queryUserByUserId(1);
        System.out.println(user);
        mv.addObject("user" , user);
        mv.setViewName("hello");
        return mv;
    }

}
